Upgraded solution to use ARC and modern objective-c syntax