fixing table sort bug