removed double replacement bug