Updated schema validation function