updating swap to not throw npe