buffer.c code is very good