halfway fixed buffer, but it's still wrong :(