correct array iteration from dictionary like to xrange