Better functions in templates