improved JS organization