fix using wrong buffer pointer