improve swapcontext and setcontext