significantly simplified switch, and got rid of final return statement, returning right ahead