Avioding complex code in the template