Fix button click handling bug