fix minor logic error