Fixed replacement logic