added isSelectionCorrect function