Split ChallengeResponse code into multiple functions.