Added helpful exception handling to alg. fix