some more general exception handling added