Fixing setInterval bug