fix ordering issue when joining elements