code from assignment 1