small refatoring and add sorted desc/asc