cleaned the code a bit