move this aside as a simpler to understand but slow version