cleaner code for template