Refactored and added rubocop