Added a goal and cleaned up the code