added max to tools.h