Added INVERT code, changed so log will append log file