changed method to add attributes to javascript from html and fixed bug when removing items from array