added final stage to genModel