made more error checks in parse and in parse-fundef