implementation of the sketch.cpp