replacestate detect