javascript fix and formatting