Updated code for iphone