Restyled JavaScript to be cleaner