moved bailout check to the end