Fix for "selection has no elements" error.