add random block generation, finish migrating over from ruby