created sub-functions; use multi line buffer (5); more debug output