working demo, template implementation and minor changes