refactoring, improved visibility of functions