core: rearrange queue when replace element