initial code import from IoTRares-v1.01