working implementation cleaned up for lecture, removed freeze