parsing the buf