added ios7 version detection, integrated code from #1