Changing class selection function to a dictionary