index out of bounce fix