final code for assignment