Implemented swap and remove/insert functions