start refactoring some code