refactored diagnose module