added 'checkOption' function

Do not repeat code too often, put it in a function :D