updated codes from assignment 3