working version before changing the echo buf