changed moving algorithm to support multiple pieces