Cleaned up code for final submission