removed the setInterval and replaced with recursive setTimeouts