Fixing broken logic