refactor confusing block + don't search the entire array

the functionality of Hash#select has changed in ruby 1.9. It now returns
a hash pairs whereas it used to return an array of pairs