reorganize function orders a bit