optimized and fixed