refactor the compact buffer