fix broken database function