updated codes from assignment 2