updated code to determine if to show or not