Use buffer and fix bugs