Wrote parsing function