Removed some deprecated code and updated it to work with jQuery 3+