Democrats perform better than expected in midterm elections