Cleaning up code and adding some comments around whats going on to make it a bit more clear