split out javascript to its own file and put subscribe functions together