Improve button sampling logic