M6: finish task 3, and small fixing