fix some potential bugs for task 3