added the rest of the functions, but previewPiece does not work correctly yet