Refactored JavaScript.p4d