added support for reverse ordering