Upgrade code to work on iOS