ENH genhyp adapted to @rgommers solution