Code for assignment 5