merge from the end