added schema creation function to determine order of fields