added file existence checks