write maximimze method