some updates and vectorization