initialization of nextbuf and prevbuf
added log statements