rubocop fixes and simplify some logic