swap fig and code