handle random in code instead of in the database