updated codes from assignment 5