improved file reading