making code more rubyesq after feedback