replaced import dialog
better index out of bounds checks