Cleaning up all the code trying to make it easier to read