Removed code repetition in vector.c