added notes and updated code with array functions