You can put the delay right before the branch.
Also, there’s no reason delays can’t be used in fucntions.