Fixed index out of bounds when removing image