reworked js part 2

cleaned up lines of code and added proper formatting