Added refDate and changed query to get last entry