Cleaned up template controller