removing cruft from demo code I borrowed