replicated changes to android (not tested)