improved button detection