refactoring the overal structure