rewriting to fit the new way to use hooks