replace setInterval with callback