using setTimeout instead of setInterval