Fixed error AttributeError: 'NoneType' object has no attribute 'replace'