Improved function for sidebars visibility