Flag value for old records is not getting changed

I have updated the source record once and after running the job I found that old and new records are getting displayed as expected.

Now the same record in source is updated again so that the other 2 records get expired in target, with flag value as 'N' and updated record gets inserted in target with Flag value 'Y'.

But it is found that only once the history is preserved, after initial update all the records are having end date as future date and Flag value set to 'Y' but ideally it should be only the last record should have end date as future date while previous records should get expire.