restructuring and adding arduino code