refactored schemeFunction architecture