Fix IP function bug