added sort option & minor changes