tidying up, making suitable for arduino