modified code according to moteid