added sort and category functionality