adding some exception handling improvements