refactoring before a gui