Change to use loop in templates instead of control