WIP: refactoring diagnose