cleaned the code a bit more