minor logic change for checking if sort exists