Initial code for wrap tags algorithm