Slighty change refresh-file function