a slightly different approach, still too slow