updated max ent code to functional version