using buffer instead of useing read line