code around getSelection bug