refactored callbacks to have some sanity