maximum value program enhanced version