cleaned up to be like what I did in class and added javadoc