added file io logic