fix code and other implementaions of code optimisation