refactoring and helper methods for gui implementation