Refactor code to buttom.