N-Gram generation logic added