Improve button rendering logic