added genmodel code