fixed error catch for agn masking