refactor to pass rubocop tests