small refactoring, more to come in existing functions.