added in more error checking, added in applySurface calls