fix rare bug on restart