I think It should be relatively easy to fix, although I know nothing about programming.
We already know what the problem is, next step is ti figure out why it is happening, then think of the potential means of fixing it. Then we'd be able to rapidly reach the point of fixing it.
[damn my professors embedding how to program with SDM specification outlining first
]