fix each function