Prevent 404 errors by checking for file existence