reduce logic from templates