change type in method swap
remove elementLength