adapt code for 4 motor drive