fixed the optimiser