Updated Code for iOS