refactors code to meet rubocop demands