buffer copying is breaking things