fixing pivoting in C lib