code tested with real ios device