cleaned up code for instructor review