try manually creating buffer, still throws invalid memory error