Implementing pagination and fix sorging table fields