fixing issue #11: generating random integers correctly