optimisation of cpu and RAM usage