fixing bugs related to date comparison