removed unused opens; moved declaration statements out of function definitions; gave a better name to the dictionary variable;