implemented update method. added test cases