working on vectorized versions