port code to objc. wip