Cleaned up the code for submission