Refactored code to use array of objects and added prototype and this ref...

...erences