code used in https://itunes.apple.com/us/course/developing-ios-7-apps-for/id733644550