fix a logic bug