Added sequence and foldM for Gen