fix bad logic