Made the guessing algorithm