added emergency stop function