updated for ios6 and above