Refactor based on Rubocop