write to file when found func ready (needs refactor), some other refactoring