refactoring, improves and code coverage