Forgot to add safe indexing function