adding check_consistency
comment out print, refactor write_to_file