Extracted code from the .crack method