sparse TD based on dann's code