ref: cleanup, cond in place of nested ifs