UIFR-118: improve the js as per Darius's suggestions