put rearrangement as function in hand.py