fixed stupid logic error