stupid logic error