really stupid logic error