added empty selection window and extracted shared methods