cleaning up code for new selection
Fixed from merge