added dynamic swap