add lifecycle callbacks