porting over to swift