Cleaned up code for hand-in