hw3 implementation