code from cs61b