minor corrections to allow compilation (some if clauses were lacking of parenthesis)