Add some cases for index out of range