Separate function for maximum calculus