Refactor warning message handling