Fixing runtime boundary violation

Avoiding referencing elements of an empty vector