refactored. working with full file