remove unneccessary computation in a template