main refactoring done