buttons actions code refactoring