Change scope for onInvalidMessages method