counter and buffer compiling