Refactor out GetNextSelection; add command replace_next

#454 
Shouldn't this return the error.