rewrite lifecycle hook system