updated function to return sorted strings