Partial refactoring to allow buttons