refactoring, main app is ok not great