Fixing vector code to be correct