initial code of carver (unfinished)