Cleaning up the code and changing formatting