increased BUFFSIZE and switched to using heap memory