expire bug fix & some refactor