Doesn't $ac\bmod m = (a\bmod m*c\bmod m)\bmod m$ and $ac\bmod m = (a\bmod m*c)\bmod m$ return the same result which are both correct
The only difference I see is $(c\bmod m)$ reduces the multiplication with $(a\bmod m)$ in the first formula. Is there any difference in the outputs for the two functions for any particular case?