When using wait() you shouldn’t expect it be right on time. You’re telling your script to wait for the given amount of time and then some extra until it can find a spot in the scheduler to continue running. Meaning the busier your scheduler gets the more likely you risk inaccurate times.
My best advice is to look for other methods of handling your loops and try to find spots where event based triggers can be used.