vectorized Version