implement writeTemplate
remove unneeded imports