I'm so truly sorry, I tried my best to fix it but run out of time in the end, so I couldn't think of a propper algorithm to fix it. I appriciate the nice comments!
Ty! I tried to fix the movement issues but just couldn't make it work :(