Refactored JavaScript, added in options.