updated codes from assignment 6