some code refactoring for codeclimate