add guard for swap