BUG : fix glaring logic errors