Restructured some JQuery and added test to see if definition is empty