button handler and switch