Improved button handling