improved optimisation, testing