Fix bugs in conditions