Tidy up code for codeclimate