added replace symbol function for self references