Added a more reliable way of reading the currently selected value.

Thanks to @sanfords for the fix.