Database now works for internal query