Fixing the logic