Cleaned up code for submission