from the app template
generator with memory 1
getting ready to do memory of n
fully generalized for arbitrary memory