Refactored to adapt to changes ot SWAP library