move init function to deviceready event