Check if the context is valid to avoid crash