fix bugs in initialization