added unpacking code for ios