Updated max code to use new function calls