started refactoring stuff