fixed pagination, implemented sorting and ordering