added complete parse function code