Refactored code
Prevent selection of an object if it's hidden