fixed bug in dynamic swap