Updated the code to Swift 1.1