trying to figure out bug in swapping pieces