added internal memory to prevent multiple file reads