refactor code in Button.