added max, min and sum functions