Fixing code to accept "PEP8"

I add some changes according to PEP8 rules, and shorten "if"s