Fixed bug in swapClass method