second version of maximum recursively