fixed sort by functionality