finally fixed stupid logic bug