refactoring, in progress. continuing..