improve button hide/show logic