refactoring js, adding in random breakpoint function