adapted HandRunCode