Optimized code, testing done