replaced some if's with switches, and some javadoc