tidy up template view codes