Moved the schema creation to outside the function