fixed potential bugs