added codeclimate and refactored