fix errors with buffer undefined