stated the template swapping code