tweaked some other code to process buttons nicely