Code from CMPS12A/L W14 at UCSC