some parallelisation and optimisation
tidying