reorganizing surface pattern code