added check for 'out of bounds' slices and made sure dialog box is deleted