Initial solution
Fixed and optimized