Simplify detection routine; enhance detection for iOS