better way to find max