Fixed auto-replacement bug