changed way selection is done, also added highlighting of selection