fix error when no element is selected