Removed whitespace and cleaned up the code with Andrew's help