Created a branching function doself1 and doself2 to switch between naive, serial and vectorised versions.