correcting a logic issue