refactor
add error handling for read file