correct study replace function