fix bugs of each function and init if function