Fix simulator bug in LMY, error in for loop condition