fix bug and add order in db

fix bug and add order in db