Refactored code based on Franco and Dan's comments

Perceived complexity for verify_set_code is too high. [8/7]