Added Max and Min function