Imported code from electricimp ide