Removed duplication in final demo replacement logic