fix bugs in init