updated code with shifts and ancestry.