Fix some logical error