fixed bugs, added external data hook