Small optimation for Ruby solution