JS code review by @hnrch02