Folding table problem with limit switch

First I try to change a better quality power supply to motor driver, and it looks better but the problem not solved (only better). And then I try to remove the 3 phase contactor (which making a little humming sound), turns out more better. Last thing is I remove the arduino power supply, and change it with dc-dc step down from 12V motor power supply to 7V arduino. Now everything is good. But I think I have to try debounce circuit just like you suggest for digital input stability, thanks for your patience answering me... God bless you