cleaned the code up a little