corrected resseting buffer