refactored some js and fixed the >100 bug