Optimized and fixed errors