use splice instead of swap