New JS

Cleaned up js and fixed the update add attr code to make fewer calls.