Made the code a little cleaner by having gen_challenge() return