My final code for programming assignment 2