sorting & finishing the renewal logic