added flipping, fixed valid_move?