replace nested IFs with COND