changed substr() to replace()