made sure clearBuffer resets its value through every iteration. I doubt this will change code execution