fix potential bugs from previous commits