finished the parsing function