some refactor to pass rubocop tests