eliminate buffer pointer and fix buffer position bug