using xrange instead of range for better performance