refine code
finish homework of week4