algorithm now running without exception