added "enumerate"; removed global variables