small logic error