Added core database query functionality