Made JS code more portable