some bug fixing due to syntax errors in some rarely used 'if' branch.