Cleaned the code a little