ready to write file for mapping but consider refactoring to make more flexible