improve button handler