added check for 'nil' paths in 'fileExistsAtPath:'