optimized implementation of restore ip addresses