first working implementation of simplex