Adding code for on destroy, pause and resume