added the 3 functions,two are not yet completed. I have the first function working that will almost resole the first problem.
it looks like mt page 2 flowchart did not commit so I did it now.