stupid logic mistake