cleaned up and commented the code a little bit