Attempt to fix the logic inside the loop of ses()