fixed an error in casting of the database query result.