use optimized flatly