Updated parsing function