updated code to better handel wrong button clicks