Modified version for running on an arduino