reformatted javascript class to be a bit cleaner