fixed  bug in calculating days before