Added type checking for vector indexing