Use local context to get messages instead of relying on global variables