moved improved logic from dummy app into templates