how to use hooks to save space