some function and public code for ios