getSelection function