Output different formats; refactoring