check before indexing a list