Fix bug where sometimes, the last entry was not returned. It was due
to picking up the max date for the right subject but wrong definitiion