Error handling for gamma