Refactoring

This uses Enumerable#min_by to fine the right method in a nicer way.