refactoring, output improvements