Pure Objective-C version. Almost OK