Modified replacement function

Modified replacement function to take extra arguments. Removed the
global variable used for convertor function.