added the writeVal function. also modifed the display array function. need to re-comment these functions