code reviewed by Christian, moved read_arduino code inside a function