updated codes from assignment 4