added function to abort if no way out found