fix exit too early problem