initial pass at swift impl