Refactured add data hook