implemented onunavailable and onservicelost event handlers