all button processing moved to switch statement for convenience