cleaned up code for final submission