Speed optimisations
Now writes results to text file