fix potential bugs related to #688