Final code for test 3