optimise code for code climate