Updated code to avoid selecting disabled controls