Code updated for XCode6.1