fix buffer passing