problem with swap function