main optimized