I've tried my best to vectorize it. | ScratchStats