almost works, but apparently I need to implement the buffer mode.