cleaned the code up a bit