refactor(server + client): code reformat and refactor pagination