Vectorized the code.