 		quad = middleQuad
 
 		#while we don't have a beginning, generate a previous token
-		while not quad?.canStart
+		while not quad.canStart
 			prevTokens = @prev[quad.hash()]
 			break if not prevTokens
 			prevToken = prevTokens[@randomInt 0, prevTokens.length-1]
 
-			newQuad = new Quad [quad.tokens[0..@markov-1]..., prevToken]
+			newQuad = new Quad [prevToken, quad.tokens[0...@markov-1]...]
 			@addQuad newQuad
 			quad = @quads[newQuad.hash()]
 			parts.unshift prevToken


			#and then get the next tokens
			if i < partsLength - @markov
				nextToken = parts[i+1]
				@next[quad.hash()] = [] if not (quad.hash() of @next)
				@next[quad.hash()].push nextToken


		if word and (word of @words) then quads = @words[word] else quads = Object.keys @quads

		#empty brain? nothing to say
		return @defaultReply if quads.length is 0

		#quads are generated differently depending on origin
		quadHash = quads[@randomInt 0, quads.length-1]
		quadHash = quadHash.tokens.join(',') if typeof quadHash isnt 'string'
		quad = middleQuad = @quads[quadHash]

		#shallow copy this guy, otherwise problems happen
		parts = quad.tokens.slice 0

		#while we don't have an end, generate a next token
		while not quad.canEnd
			nextTokens = @next[quad.hash()]

			#no tokens, no dice -- skip
