fixed applyCustomTemplate