updated functions with new schemas and better error reporting