improve the script for handling the dropw down visibility function