fixed the error on replace