handles for database query