Added some guards in file utils.