Added the speed test and speed up the loops