used foldM in applySeq