updated js file to use arrays