filtering and sorting templates fixed