cleaned the code a little