basic algorithm mostly done, max(*) -> max{*}