modified for programming assignment 2