rubocop and refactor for readability