Refactor iOS8 Safari fix