work from mit's 6.001 iap class