repair writeTemplate and belongsTo