refactoring output and clean it from HTML