Part of Lab 6 for CS 235