refactor for deviceready