Add option to iterate in reverse order