fixes for sorting