fix bugs, add some utils