separating generic code from the demo