Created hook function