Refactor codes according to Rubocop