updated code to hide elements which aren't populated