add some code to support file exists