fixed a potential bug in SWD