Swift implementation