fix some bug to work on iOS