Ensure that index is valid when searching