why not pass the version to the command factory and allow it to decide which type of replace command to build? This way you'd reuse this if logic.