refactor based on code climate rating