modified the parsing function