updated arduino script for better reset