Used NumPy to make things speedy