Put repetitive code of option checking into functions.