adding new refractored code and JQuery