again big refactoring