Modify top k selection and serialize data