debugged up through discrete functions