Moving functional definitions from original demo