changed range

changed some range with xrange for optimization