Refactoring the javascritp
Adduing document ready
typos after refactor
typo