Applied DRY Principle on JQuery