adding in support for sorting and fixing return field support