TypeError: Cannot read property 'replace' of null