not working version (in development) - started writing optimisation