a few more utlity functions, fix bug in max or take