add closure to fix filestream reference errors