#294 use database for random calculation