Changed the replaceByName method signature to make it clearer