reworked the code that sends data to iPad