improved button handling