this can also be done as a vector operation