Cleared up the code a bit