Fixed code for Swift. Both parts now work.