Cleaning up the code to match my own style