fix issue with null ctx pointer