added random patch generator