fix bug in vectorization