You could look into [limit](http://guides.rubyonrails.org/active_record_querying.html#limit-and-offset) which will eliminate the need for the if on line 21.