optimized preprocessing