final version of JS functionality added