shorten sort, filter code