Completed code refactor, uing singel var patterns and converting jquery to native JS for selectors