fixed a bug in the database when cloning from template