refactor document ready js application