completing the code stubs from assignment