fixed serious bugs in the model template