fixed Javascript and duplication issues