fixed recursive bug