fix for logic error