fixed some bugs ad improved date-finding mechanism