major code optimisation
scaled down changes