Refactor extract messages