refactor with callback pattern, still doesn't solve issue