add some additional safety checks to try and ferrit out a bug
better way of propagating the exception