added changes from prof h's commit