Adds result type and sorting