         else
           # show board
           showBoard(@board)
+
       else
         console.log "Invalid"
 

move = (board, direction) ->
  newBoard = buildBoard()
  for i in [0..3]
    if direction is 'right' or direction is 'left'
      row = getRow(i, board)
      row = mergeCells(row, direction)
      row = collapseCells(row, direction)
      setRow(row, i, newBoard)
    else if direction is 'up' or direction is 'down'
      column = getCol(i, board)
      column = mergeCells(column, direction)
      column = collapseCells(column, direction)

        else if cell[b] isnt 0 then break
    cell

  if direction in ['right', 'down']
    merge cell
  else if direction in ['left', 'up']
    merge(cell.reverse()).reverse()

collapseCells = (cell, direction) ->
  cell = cell.filter (ele) -> ele isnt 0
  while cell.length < 4
    if direction in ['right', 'down']
      cell.unshift 0
    else if direction in ['left', 'up']
      cell.push 0
  cell

