added file exists check