Final Code with Modification to Array