sanity refactor with callbacks