got rid of duplicated selection code, fixes #2