move getVal out of vectorized loop