functions for output have been changed to private.