added snippets to check if file/directory exists