fix condition bugs