range check before accessing vectors just to be safe