code given by Lander in cs140