improve read file method