fix crash with nil context