Fixed error: 'TypeError: Cannot call method 'replace' of null'