boilerplate and working implementation (almost no testing)