fixing bad logic