So we found out that the reason the motors were twitching. Just like you said it was happening because the wiring was wrong initially but then once fixed it continued doing the same thing. We found that the driver chips were fried. so we got a new board and it fixed it.