It would be best to simplify this logic, even if it means compromising the one liner. Also another use of $.grep which should be interchangeable with Array.filter.