improved vectorized versions