fix rubocop, minor refactoring