another addition to make arnes sql to avoid race conditions work, apparently NULL is not less than 1 in mysql