lab4 implementation