finished  setType function