Add definition to choosePivot function