major refactoring, moved code to providers