big refactoring. 1