corrected a logic error