Added pattern genearator function