fix bugs in init script