some codes for cocoa