fix exit from fucation