Updated code to use new hooks