updated parsing function