           row[b] = 0
           break
         else if row[b] isnt 0 then break
+
+  else if direction is 'left'
+    for a in [0...3]
+      for b in [a+1..3]
+
+        if row[a] is 0 then break
+        else if row[a] == row[b]
+          row[a] *= 2
+          row[b] = 0
+          break
+        else if row[b] isnt 0 then break
   row
-
-# console.log mergeCells [4,4,4,4], 'right'
 
 collapseCells = (row, direction) ->
   row = row.filter (ele) -> ele isnt 0

      # try moving
      newBoard = move(@board, direction)
      printArray newBoard
      if moveIsValid(@board, newBoard)
        console.log "Valid"
        @board = newBoard
        generateTile(@board)
        showBoard(@board)
      else
        console.log "Invalid"


      row.push 0
  row

moveIsValid = (originalBoard, newBoard) ->
  for row in [0..3]
    for col in [0..3]
      if originalBoard[row][col] isnt newBoard[row][col]
        return true
  false

boardIsFull = (board) ->
  for row in board
    if 0 in row
      return false
  true

noValidMove = (board) ->
  direction = 'right' #FIXME: Handle other directions
  newBoard = move(board, direction)
  if moveIsValid(board, newBoard)
    return false
  true

isGameOver = (board) ->
  boardIsFull(board) and noValidMove(board)

showBoard = (board) ->
  for row in [0..3]
