add delta max funciton
merge