improve arduino read command logic