added scratch buffer