removed inline JS and used JQuery to implement the same logic