simple and doc

simplified the IF statements and documented a little more