corrected regex again and added mutex for ip allocation